public class Text2 {
    //3.无重复字符串的最长子串
    public int lengthOfLongestSubstring(String s) {
        int[] hash = new int[128];
        char[] s1 = s.toCharArray();

        int left = 0, right = 0,n = s.length(),ret = 0;
        while(right < n){
            hash[s1[right]]++;
            {
                while(hash[s1[right]]>1){
                    hash[s1[left++]]--;
                }
                ret = Math.max(ret,right - left + 1);
                right++;
            }
        }
        return ret;
    }
}
